package de.lmu.mvs.lerngruppenfinder.utils;

import java.util.Comparator;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import de.lmu.mvs.lerngruppenfinder.DashboardActivity.Group;

public class DateDistanceComparator implements Comparator {

	@Override
	public int compare(Object lhs, Object rhs) {
		Group group1 = (Group) lhs;
		Group group2 = (Group) rhs;
		
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
		DateTime date1 = format.parseDateTime(group1.datum);
		DateTime date2 = format.parseDateTime(group2.datum);
		
		int compare = date1.compareTo(date2);
		return compare;
	}

	private int calculate(float distance1, float distance2) {
		if (distance1 < distance2)
			return -1;
		if (distance1 > distance2)
			return 1;
		return 0;
	}
}
